Skip to content

feat(server-utils): Migrate OpenAI integration to orchestrion - #21877

Merged
nicohrubec merged 3 commits into
developfrom
nh/openai-orchestrion
Jul 3, 2026
Merged

feat(server-utils): Migrate OpenAI integration to orchestrion#21877
nicohrubec merged 3 commits into
developfrom
nh/openai-orchestrion

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Jul 1, 2026

Copy link
Copy Markdown
Member

Adds an orchestrion based OpenAI integration to server-utils, covering all the APIs and both streaming and non-streaming mode. Leaves the core integration intact and only exports the necessary utils that are needed for the orchestrion integration.

Closes #20912

Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts
Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
@nicohrubec
nicohrubec force-pushed the nh/openai-orchestrion branch from b53ebd6 to 8149b88 Compare July 1, 2026 09:29
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.24 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.01 kB - -
@sentry/browser (incl. Tracing, Replay) 85.49 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.1 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.19 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.84 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.51 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.11 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.22 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.53 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.77 kB - -
CDN Bundle (incl. Tracing, Replay) 85.68 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.77 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.92 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.89 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.59 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.93 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.89 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.58 kB - -
@sentry/nextjs (client) 50.95 kB - -
@sentry/sveltekit (client) 46.65 kB - -
@sentry/core/server 78.31 kB +0.05% +34 B 🔺
@sentry/core/browser 64.66 kB +0.08% +46 B 🔺
@sentry/node-core 63.17 kB - -
@sentry/node 123.15 kB -0.01% -2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.7 kB - -
@sentry/node - without tracing 74.22 kB - -
@sentry/aws-serverless 85.01 kB - -
@sentry/cloudflare (withSentry) - minified 181.52 kB - -
@sentry/cloudflare (withSentry) 449.12 kB - -

View base workflow run

@nicohrubec
nicohrubec force-pushed the nh/openai-orchestrion branch 2 times, most recently from e03ecce to 856774b Compare July 1, 2026 10:15
Comment thread packages/node/src/sdk/experimentalUseDiagnosticsChannelInjection.ts Outdated
@nicohrubec
nicohrubec force-pushed the nh/openai-orchestrion branch 5 times, most recently from 127e3b2 to c9ec0e1 Compare July 1, 2026 11:14
@nicohrubec nicohrubec changed the title feat(node): Port OpenAI chat completions to orchestrion feat(node): Add orchestrion-based OpenAI integration Jul 1, 2026
@nicohrubec nicohrubec changed the title feat(node): Add orchestrion-based OpenAI integration feat(server-utils): Migrate OpenAI integration to orchestrion Jul 1, 2026
@nicohrubec nicohrubec changed the title feat(server-utils): Migrate OpenAI integration to orchestrion feat(server-utils): Migrate OpenAI integration to orchestrion (non-streaming) Jul 1, 2026
@nicohrubec nicohrubec changed the title feat(server-utils): Migrate OpenAI integration to orchestrion (non-streaming) feat(server-utils): Migrate OpenAI integration to orchestrion Jul 1, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9ca6a54. Configure here.

Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts
@nicohrubec
nicohrubec marked this pull request as ready for review July 1, 2026 16:42
@nicohrubec
nicohrubec requested a review from a team as a code owner July 1, 2026 16:42
@nicohrubec
nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a team July 1, 2026 16:42
Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/node';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: I think these tests can be removed after #21911 has been rebased?

@nicohrubec
nicohrubec force-pushed the nh/openai-orchestrion branch from 30a9558 to db3e09b Compare July 2, 2026 14:47
Adds the orchestrion diagnostics-channel OpenAI integration (chat, responses,
embeddings, conversations) and registers it in the channelIntegrations map.
Skips span creation when a higher-level provider (e.g. langchain) already
instruments the SDK to avoid double spans.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubec force-pushed the nh/openai-orchestrion branch from db3e09b to 62e81c0 Compare July 2, 2026 16:15
Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts
Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
nicohrubec and others added 2 commits July 3, 2026 08:33
# Conflicts:
#	packages/server-utils/src/orchestrion/index.ts
… integration

Let errors bubble to the global handlers instead of capturing them as unhandled
at the instrumentation level, matching the DB/cache channel subscribers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread packages/server-utils/src/integrations/tracing-channel/openai.ts
@nicohrubec
nicohrubec merged commit 27f34ed into develop Jul 3, 2026
297 checks passed
@nicohrubec
nicohrubec deleted the nh/openai-orchestrion branch July 3, 2026 07:44
lux-in-tenebris-lucet pushed a commit to lux-in-tenebris-lucet/sentry-javascript that referenced this pull request Aug 8, 2026
… instrumentation level

The exported instrumentOpenAiClient, instrumentAnthropicAiClient and
instrumentGoogleGenAIClient wrappers captured provider errors with
mechanism.handled = false and then rethrew, so the SDK classified the
error as an unhandled crash before the application's retry or fallback
logic ran. A call that succeeded on retry still produced an unhandled
event, and each retry produced another one.

Applies the convention established for the channel-based OpenAI
integration in getsentry#21877 to the manual client instrumentation, which is the
only available path on the edge and serverless runtimes. Error span
status and the original error identity are unchanged.

The anthropic suite asserted this divergence directly, expecting the
model-error event only while orchestrion was disabled. Both paths agree
now, so that branch and its expectation are gone.

Captures are kept where a provider reports an error as data on an
otherwise successful call, since the caller never sees those as a thrown
error. The AI integration suites no longer mask these events with
.ignore('event'), so they fail if the capture returns.

Dropping the capture also left the .catch() in createWithResponseWrapper
rethrowing into a promise nothing observes, which is not a handler at
all: awaiting the two promises in sequence orphans the second whenever
the first rejects. They are awaited together now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite SentryOpenAiInstrumentation to orchestrion

4 participants